<!-- 学校告警-批量督办 -->
<template>
  <view class="index-all">
    <Header title="批量督办" :autoBack="false" @leftClick="goBack" />
    <view class="list-box">
      <scroll-view class="list-all" scroll-y="true">
        <uv-form ref="form" :errorType="errorType" :model="formData" :rules="rules" labelWidth="150">
          <view class="form-box textAlignLeft">
            <uv-form-item label="督办意见" prop="opinions" labelPosition="top">
              <template #label>
                <view class="requireStar">督办意见</view>
              </template>
              <view class="areaWidth">
                <uv-textarea v-model="formData.opinions" placeholder="请输入督办意见" height="116rpx" maxlength="200" count></uv-textarea>
              </view>
            </uv-form-item>
          </view>
        </uv-form>
      </scroll-view>
    </view>
    <view class="sure-button-box" style="width: 100%">
      <button class="sure-button" :disabled="loading" @tap="submit">确认</button>
    </view>
  </view>
</template>

<script setup>
  import api from "@/api/pco/alarm/alarmInfo.js";
  const {proxy} = getCurrentInstance();
  const form = ref();
  const errorType = ref('message');
  let loading = ref(false);

  let formData = reactive({
    alarmUrgeState:'1',
    urgeUserId: uni.getStorageSync('userInfo').user.id,
    urgeUserName:uni.getStorageSync('userInfo').user.nickName,
    opinions: '',
    urgeSignature: '',
  });

  const rules = reactive({
    opinions: [
      {
        type: 'string',
        required: true,
        message: '请输入督办意见',
        trigger: ['change', 'blur']
      }
    ],
  });

  let ids = ref([]);

  onLoad((e) => {
    if (e.ids) {
      ids.value = JSON.parse(e.ids)
    }
  });

  /** 确认按钮 */
  let submit = (e) => {
    formData.ids = [...ids.value]
    form.value.validate().then(res => {
      proxy.http.post(api.alarmBatchUpdateUrgeInfo, formData).then(res => {
        if (res.code === 0) {
          uni.showToast({title: '督办成功', icon: 'success', duration: 2000});
          setTimeout(() => {
            goBack();
          }, 1000)
        } else {
          uni.showToast({title: res.msg, icon: 'none'})
        }
      })
    })
  }

  /** 返回上一页 **/
  let goBack = (e) => {
    uni.$emit("refresh", {});
    uni.navigateBack();
  }
</script>

<style scoped lang="scss">
  .index-all{
    position: relative;
    background: #f6f6f6;
    height: 100vh;
  }

  .list-box {
    margin: 20rpx 16rpx;
  }
  .list-all {
    background: #ffffff;
    padding: 0 20rpx;
    border-radius: 10rpx;
  }
  .areaWidth {
    margin: 24rpx 0rpx 0rpx;
    width: 100%;
    ::v-deep .uv-textarea {
      padding: 0;
    }
    ::v-deep .uv-textarea__field{
      text-align: left!important;
      padding: 10px!important;
    }

  }
  ::v-deep .uv-form-item__body {
    padding: 0 !important;
  }
  //::v-deep .uv-form-item__body {
  //  padding: 32rpx 0!important;
  //}
</style>